package com.fyzk.activity.trend;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.RadioButton;

import com.fyzk.data.AppLotteryInfos;
import com.tyjc.lottery.R;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.utils.LotteryIDUtils;

import java.util.List;

/**
 * Created by fanxs11 on 2017/7/20.
 * 排列3走势图
 */

public class PL3TrendActivity extends TrendBaseActivity implements CompoundButton.OnCheckedChangeListener {


    private RadioButton rb1;
    private RadioButton rb2;
    private RadioButton rb3;
    private RadioButton rb4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    protected String getTopTitle() {
        return AppLotteryInfos.getLotteryName(getLotteryType());
    }

    @Override
    protected View getChooseView() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.view_gp11x5_trend_choose, null);
        view.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        rb1 = (RadioButton) view.findViewById(R.id.trend_choose_rb1);
        rb2 = (RadioButton) view.findViewById(R.id.trend_choose_rb2);
        rb3 = (RadioButton) view.findViewById(R.id.trend_choose_rb3);
        rb4 = (RadioButton) view.findViewById(R.id.trend_choose_rb4);

        rb1.setText("百位");
        rb2.setText("十位");
        rb3.setText("个位");

        rb4.setVisibility(View.GONE);
        rb1.setChecked(true);

        rb1.setOnCheckedChangeListener(this);
        rb2.setOnCheckedChangeListener(this);
        rb3.setOnCheckedChangeListener(this);
        rb4.setOnCheckedChangeListener(this);

        trendView.chooseId = R.id.trend_choose_rb1;

        return view;
    }

    @Override
    protected TrendBaseView getTrendView() {
        return new PL3TrendView(getContext());
    }

    @Override
    protected String getBetCode(List<TrendBaseView.Drawinfor> infors) {
        return null;
    }

    @Override
    protected long getZhuShu(List<TrendBaseView.Drawinfor> infors) {
        return 0;
    }

    @Override
    protected int getLotteryType() {
        return getIntent().getIntExtra(IntentParamUtils.LOTTERYID, LotteryIDUtils.PL3_LOTTERY_ID_INT);
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            if (trendView.listener != null) {
                trendView.listener.onChooseClick(buttonView.getId());
            }
        }
    }

    @Override
    protected void setInfors(List<List<Integer>> infors, List<String> phaseInfors) {
        super.setInfors(infors, phaseInfors);
        if (trendView.listener != null) {
            trendView.listener.onChooseClick(trendView.chooseId);
        }
    }
}
